package top.tenebrous.yzl.im.factory.colony;

import org.springframework.stereotype.Component;
import top.tenebrous.yzl.im.enums.MessageType;
import top.tenebrous.yzl.im.enums.ProducerType;
import top.tenebrous.yzl.im.sender.AbstractSenderHandler;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author yazhang6
 */
@Component
public class MessageQueueFactoryHandler implements MessageQueueFactory{

    private final Map<ProducerType, AbstractSenderHandler> producer = new ConcurrentHashMap<>();

    @Override
    public void registerProducer(ProducerType producerType, AbstractSenderHandler senderHandler) {
        producer.put(producerType, senderHandler);
    }

    @Override
    public AbstractSenderHandler getProducerInstance(ProducerType producerType) {
        return producer.get(producerType);
    }
}
